$OpenBSD: patch-despoof_c,v 1.3 2005/03/15 01:37:06 mjc Exp $
--- despoof.c.orig	Tue Jul 25 07:51:24 2000
+++ despoof.c	Mon Mar 14 10:51:17 2005
@@ -34,7 +34,7 @@ struct bpf_program pcapfilter;
 struct in_addr net, mask;
 pcap_t *pd;
 char pcap_err[PCAP_ERRBUF_SIZE];
-u_char *ebuf;
+u_char ebuf[LIBNET_ERRBUF_SIZE];
 char *dev;
 struct libnet_link_int *l;
 int num_of_questions, link_offset, verbose, target_answers, unexpected, inquery;
@@ -150,7 +150,7 @@ void grab_packet(u_char *data1, struct p
 
   if (targetaddr == ip->ip_src.s_addr) 
   {
-    if (((inquery == 1) && (icmp->icmp_type == ICMP_ECHOREPLY)) || ((inquery == 2) && (icmp->icmp_type == ICMP_TIMESTAMPREPLY)) || ((inquery == 3) && (sport == ntohs(tcphdr->th_dport))))
+    if (((inquery == 1) && (icmp->icmp_type == ICMP_ECHOREPLY)) || ((inquery == 2) && (icmp->icmp_type == ICMP_TSTAMPREPLY)) || ((inquery == 3) && (sport == ntohs(tcphdr->th_dport))))
     {
       if (ttlval == ip->ip_ttl)
       {
@@ -285,7 +285,7 @@ void usage(char *prog)
   fprintf(stderr,"    -a set ACK flag on TCP packets\n");
   fprintf(stderr,"    -h this help screen\n");
   fprintf(stderr,"    -v verbose\n");
-  fprintf(stderr,"  -d device to grab local IP or sniff from, default is eth0\n");
+  fprintf(stderr,"  -d device to grab local IP or sniff from\n");
   fprintf(stderr,"  -l local port to bind to, default is 80\n");
   fprintf(stderr,"  -p target port to send to, default is 80\n");
   fprintf(stderr,"  -i inquery packet type to send/receive, types include the following:\n");
@@ -306,12 +306,12 @@ int main(int argc, char **argv)
   extern int optind;
   extern int optopt;
   extern int opterr;
-  char ch;
+  int ch;
   int spoof = 0, setdev = 0, timeout = 10, ttl = 0;
   u_long dst_ip = 0;
   pid_t pid;
   
-  dev = "eth0"; /* default */
+  dev = NULL;
   verbose = 0;
   prog = argv[0];
   sport = 80;
@@ -408,6 +408,16 @@ int main(int argc, char **argv)
     fprintf(stderr, "=== and spoof your source IP address at the same time.\n");
     usage(prog);
     exit(-1);
+  }
+
+  if (dev == NULL) 
+  {
+    dev = pcap_lookupdev(pcap_err);
+    if (dev == NULL) 
+    {
+      fprintf(stderr, "=== No devices found.\n");
+      exit(-1);
+    }
   }
 
   if(!spoof)
